package com.ruoyi.web.TemuEvents.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.TemuEvents.domain.TemuEvents;
import com.ruoyi.web.TemuEvents.service.ITemuEventsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * TemuEventsController
 * 
 * @author kzc
 * @date 2025-07-25
 */
@RestController
@RequestMapping("/TemuEvents/events")
public class TemuEventsController extends BaseController
{
    @Autowired
    private ITemuEventsService temuEventsService;



    @PostMapping("/insTemuEvents")
    public AjaxResult instemuevents(String cokie,String mallid) throws IOException {
        temuEventsService.insTemuEvents(cokie,mallid);
        return AjaxResult.success();
    }




    /**
     * 查询TemuEvents列表
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:list')")
    @GetMapping("/list")
    public TableDataInfo list(TemuEvents temuEvents)
    {
        startPage();
        List<TemuEvents> list = temuEventsService.selectTemuEventsList(temuEvents);
        return getDataTable(list);
    }

    /**
     * 导出TemuEvents列表
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:export')")
    @Log(title = "TemuEvents", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TemuEvents temuEvents)
    {
        List<TemuEvents> list = temuEventsService.selectTemuEventsList(temuEvents);
        ExcelUtil<TemuEvents> util = new ExcelUtil<TemuEvents>(TemuEvents.class);
        util.exportExcel(response, list, "TemuEvents数据");
    }

    /**
     * 获取TemuEvents详细信息
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(temuEventsService.selectTemuEventsById(id));
    }

    /**
     * 新增TemuEvents
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:add')")
    @Log(title = "TemuEvents", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TemuEvents temuEvents)
    {
        return toAjax(temuEventsService.insertTemuEvents(temuEvents));
    }

    /**
     * 修改TemuEvents
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:edit')")
    @Log(title = "TemuEvents", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TemuEvents temuEvents)
    {
        return toAjax(temuEventsService.updateTemuEvents(temuEvents));
    }

    /**
     * 删除TemuEvents
     */
    @PreAuthorize("@ss.hasPermi('TemuEvents: events:remove')")
    @Log(title = "TemuEvents", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(temuEventsService.deleteTemuEventsByIds(ids));
    }
}
